import { QuoteResponse } from '@metamask/bridge-controller';
import { SimulationTokenStandard } from '@metamask/transaction-controller';

import {
  getBestQuote,
  getDataFromSwap,
  getBalanceChangeFromSimulationData,
  parseTransactionData,
  checkValidSingleOrBatchTransaction,
} from './dapp-swap-comparison-utils';

const MOCK_QUOTES = [
  {
    quote: {
      requestId:
        '0x953edd7a1725891162e49f7a1e449522abd8209dd7377b8772d04edaba02de44',
      bridgeId: 'kyberswap',
      srcChainId: 42161,
      destTokenAmount: '45',
      minDestTokenAmount: '40',
      walletAddress: '0x178239802520a9C99DCBD791f81326B70298d629',
    },
    approval: {
      gasLimit: 15,
    },
    trade: { gasLimit: 18 },
    estimatedProcessingTimeInSeconds: 0,
  },
  {
    quote: {
      requestId:
        '0x9ade5d2412cacb2c2332108aa83c759a84f39ab72c931da3296fbe8733f3b7f3',
      bridgeId: '0x',
      srcChainId: 42161,
      destTokenAmount: '98',
      minDestTokenAmount: '90',
      walletAddress: '0x178239802520a9C99DCBD791f81326B70298d629',
    },
    approval: {
      gasLimit: 22,
    },
    trade: { gasLimit: 34 },
    estimatedProcessingTimeInSeconds: 0,
  },
  {
    quote: {
      requestId:
        '0x18359d76a875338da1b455a4f22ab88f4ec467d64e89df5d2daf5e37f7d2f1be',
      bridgeId: 'okx',
      srcChainId: 42161,
      destTokenAmount: '96',
      minDestTokenAmount: '90',
    },
    approval: {
      gasLimit: 20,
    },
    trade: { gasLimit: 30 },
    estimatedProcessingTimeInSeconds: 0,
  },
];

describe('dapp-swap utils', () => {
  describe('parseTransactionData', () => {
    it('returns the correct result', () => {
      const data =
        '0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000068f0dd1b0000000000000000000000000000000000000000000000000000000000000003100604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000044000000000000000000000000000000000000000000000000000000000000004c000000000000000000000000000000000000000000000000000000000000003c0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003070b0e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000005af3107a4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e58310000000000000000000000007ffc3dbf3b2b50ff3a1d5523bc24bb5043837b1400000000000000000000000000000000000000000000000000000000000000190000000000000000000000000000000000000000000000000000000000000060000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831000000000000000000000000178239802520a9c99dcbd791f81326b70298d62900000000000000000000000000000000000000000000000000000000000601470c';
      const { commandBytes, inputs } = parseTransactionData(data);
      expect(commandBytes).toStrictEqual(['10', '06', '04']);
      expect(inputs).toStrictEqual([
        '0x000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003070b0e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000005af3107a4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000',
        '0x000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e58310000000000000000000000007ffc3dbf3b2b50ff3a1d5523bc24bb5043837b140000000000000000000000000000000000000000000000000000000000000019',
        '0x000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831000000000000000000000000178239802520a9c99dcbd791f81326b70298d6290000000000000000000000000000000000000000000000000000000000060147',
      ]);
    });
  });
  describe('getDataFromSwap', () => {
    it('returns the correct data from native -> erc20 swap', () => {
      const result = getDataFromSwap(
        '0xa4b1',
        ['10', '06', '04'],
        [
          '0x000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003070b0e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000005af3107a4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000',
          '0x000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e58310000000000000000000000007ffc3dbf3b2b50ff3a1d5523bc24bb5043837b140000000000000000000000000000000000000000000000000000000000000019',
          '0x000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831000000000000000000000000178239802520a9c99dcbd791f81326b70298d6290000000000000000000000000000000000000000000000000000000000060147',
        ],
      );
      expect(result).toStrictEqual({
        amountMin: '0x060147',
        quotesInput: {
          destChainId: '0xa4b1',
          destTokenAddress: '0xaf88d065e77c8cc2239327c5edb3a432268e5831',
          gasIncluded: false,
          gasIncluded7702: false,
          srcChainId: '0xa4b1',
          srcTokenAddress: '0x0000000000000000000000000000000000000000',
          srcTokenAmount: '0x5af3107a4000',
        },
      });
    });
    it('returns the correct data from erc20 -> erc20 swap', () => {
      const result = getDataFromSwap(
        '0xa4b1',
        ['10'],
        [
          '0x000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003070b0e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000064000000000000000000000000000000000000000000000000000000000000005f00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000fd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb900000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000fd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9000000000000000000000000178239802520a9c99dcbd791f81326b70298d6290000000000000000000000000000000000000000000000000000000000000000',
        ],
      );
      expect(result).toStrictEqual({
        amountMin: '0x5f',
        quotesInput: {
          destChainId: '0xa4b1',
          destTokenAddress: '0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9',
          gasIncluded: false,
          gasIncluded7702: false,
          srcChainId: '0xa4b1',
          srcTokenAddress: '0xaf88d065e77c8cc2239327c5edb3a432268e5831',
          srcTokenAmount: '0x64',
        },
      });
    });
  });

  describe('getBestQuote', () => {
    it('returns the best quote', () => {
      const result = getBestQuote(
        MOCK_QUOTES as unknown as QuoteResponse[],
        '0x32',
        (val) => val,
        (val) => val.toString(),
      );
      expect(result.bestQuote).toBe(MOCK_QUOTES[2]);
      expect(result.bestFilteredQuote).toBe(MOCK_QUOTES[2]);
    });

    it('bestFilteredQuote is undefined if no quote has minimum amount greater than confirmation', () => {
      const result = getBestQuote(
        MOCK_QUOTES as unknown as QuoteResponse[],
        '0x64',
        (val) => val,
        (val) => val.toString(),
      );
      expect(result.bestQuote).toStrictEqual(MOCK_QUOTES[2]);
      expect(result.bestFilteredQuote).toBe(undefined);
    });

    it('returns undefined for empty quotes array', () => {
      const result = getBestQuote(
        [] as unknown as QuoteResponse[],
        '0x32',
        (val) => val,
        (val) => val.toString(),
      );
      expect(result.bestQuote).toBe(undefined);
      expect(result.bestFilteredQuote).toBe(undefined);
    });
  });

  describe('getBalanceChangeFromSimulationData', () => {
    it('returns the correct value for token address', () => {
      const result = getBalanceChangeFromSimulationData(
        '0xaf88d065e77c8cc2239327c5edb3a432268e5831',
        {
          tokenBalanceChanges: [
            {
              address: '0xaf88d065e77c8cc2239327c5edb3a432268e5831',
              difference: '0x64',
              standard: SimulationTokenStandard.erc20,
              previousBalance: '0x0',
              newBalance: '0x0',
              isDecrease: true,
            },
          ],
        },
      );
      expect(result).toBe('100');
    });
    it('returns 0 if simulation data is not provided', () => {
      const result = getBalanceChangeFromSimulationData(
        '0xaf88d065e77c8cc2239327c5edb3a432268e5831',
        undefined,
      );
      expect(result).toBe('0');
    });
    it('returns 0 if record is not found', () => {
      const result = getBalanceChangeFromSimulationData('0x123', {
        tokenBalanceChanges: [],
      });
      expect(result).toBe('0');
    });
  });

  describe('checkValidSingleOrBatchTransaction', () => {
    it('throws error for single transaction with invalid data', () => {
      expect(() =>
        checkValidSingleOrBatchTransaction([{ data: '0x' }]),
      ).toThrow(
        'Error getting data from swap: invalid batch transaction, invalid command',
      );
    });
    it('returns undefined for valid batch transaction', () => {
      expect(
        checkValidSingleOrBatchTransaction(
          [
            {
              to: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
              data: '0x095ea7b3000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba3000000000000000000000000000000000000000000000000000000000007a120',
              value: '0x0',
            },
            {
              to: '0x000000000022D473030F116dDEE9F6B43aC78BA3',
              data: '0x87517c45000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000066a9893cc07d91d95644aedd05d03f95e1dba8af000000000000000000000000000000000000000000000000000000000007a1200000000000000000000000000000000000000000000000000000000069274d75',
              value: '0x0',
            },
            {
              to: '0x66a9893cc07d91d95644aedd05d03f95e1dba8af',
              data: '0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000069274d750000000000000000000000000000000000000000000000000000000000000002100c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000440000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000004070c100e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000007a120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000007a1200000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000058c51ee8998e8ef06362df26a0d966bbd0cf511300000000000000000000000000000000000000000000000000000000000013880000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000005206d14bfa10bd18989038fe628a79a135f2ee2f0000000000000000000000000000000000000000000000000000000000000000',
              value: '0x0',
            },
          ],
          '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
        ),
      ).toStrictEqual(undefined);
      expect(
        checkValidSingleOrBatchTransaction(
          [
            {
              to: '0x000000000022D473030F116dDEE9F6B43aC78BA3',
              data: '0x87517c45000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000066a9893cc07d91d95644aedd05d03f95e1dba8af000000000000000000000000000000000000000000000000000000000007a1200000000000000000000000000000000000000000000000000000000069274d75',
              value: '0x0',
            },
            {
              to: '0x66a9893cc07d91d95644aedd05d03f95e1dba8af',
              data: '0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000069274d750000000000000000000000000000000000000000000000000000000000000002100c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000440000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000004070c100e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000007a120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000007a1200000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000058c51ee8998e8ef06362df26a0d966bbd0cf511300000000000000000000000000000000000000000000000000000000000013880000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000005206d14bfa10bd18989038fe628a79a135f2ee2f0000000000000000000000000000000000000000000000000000000000000000',
              value: '0x0',
            },
          ],
          '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
        ),
      ).toStrictEqual(undefined);
      expect(
        checkValidSingleOrBatchTransaction(
          [
            {
              to: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
              data: '0x095ea7b300000000000000000000000066a9893cc07d91d95644aedd05d03f95e1dba8af000000000000000000000000000000000000000000000000000000000007a120',
              value: '0x0',
            },
            {
              to: '0x66a9893cc07d91d95644aedd05d03f95e1dba8af',
              data: '0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000069274d750000000000000000000000000000000000000000000000000000000000000002100c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000440000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000004070c100e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000007a120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000007a1200000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000058c51ee8998e8ef06362df26a0d966bbd0cf511300000000000000000000000000000000000000000000000000000000000013880000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000005206d14bfa10bd18989038fe628a79a135f2ee2f0000000000000000000000000000000000000000000000000000000000000000',
              value: '0x0',
            },
          ],
          '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
        ),
      ).toStrictEqual(undefined);
    });

    it('throws error if number of nested transactions is greater than 3', () => {
      expect(() =>
        checkValidSingleOrBatchTransaction([
          { data: '0x' },
          { data: '0x' },
          { data: '0x' },
          { data: '0x' },
        ]),
      ).toThrow(
        'Error getting data from swap: invalid batch transaction maximum 3 nested transactions allowed',
      );
    });
  });
});
